Skip to content

feat: add support of negation config rules#266

Open
achxkloel wants to merge 2 commits intomainfrom
feat/add_support_of_negation_config_rules
Open

feat: add support of negation config rules#266
achxkloel wants to merge 2 commits intomainfrom
feat/add_support_of_negation_config_rules

Conversation

@achxkloel
Copy link
Copy Markdown
Collaborator

Description

Adds support of negation config rules:

Example:

config = [
    "sdkconfig.*=",
    "!sdkconfig.test",
]

Will match sdkconfig.foo, sdkconfig.bar, but not sdkconfig.test

More information in documentation.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for “negation” config rules (prefixed with !) so users can exclude specific sdkconfig* files/patterns from the discovered build configurations.

Changes:

  • Extend config-rule parsing to support !pattern negation rules (and document the supported formats).
  • Apply negation rules during app discovery to filter out matched sdkconfig paths after inclusion rules.
  • Add tests and update CLI help + documentation with negation examples.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_finder.py Adds parametrized tests covering basic/multiple/wildcard negation scenarios plus an invalid-format test.
idf_build_apps/utils.py Extends ConfigRule to carry a negated flag and updates config_rules_from_str to parse ! rules.
idf_build_apps/finder.py Skips negated rules during inclusion pass and applies them afterward to remove matching sdkconfig paths.
idf_build_apps/args.py Updates --config-rules help text to mention ! negation rules and their application order.
docs/en/references/config_file.rst Updates configuration-file examples to include a negation rule.
docs/en/explanations/find.rst Documents usage of negation rules with idf-build-apps find.
docs/en/explanations/config_rules.rst Documents negation rule syntax and adds examples to the config-rules table.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread idf_build_apps/utils.py
Comment on lines +66 to +68
negated_str = rule_str[1:]
if '=' in negated_str:
raise InvalidInput(f'Negation rules must not have a config name: {rule_str}')
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config_rules_from_str accepts a negation rule of just ! (or ! followed by whitespace), which produces ConfigRule(file_name=''). This later reaches Path(path).glob(rule.file_name) in finder.py and will raise at runtime for an empty glob pattern. Please validate negated_str is non-empty (and ideally .strip() it) and raise InvalidInput with a clear message when the pattern is empty; adding a small unit test for this case would prevent regressions.

Suggested change
negated_str = rule_str[1:]
if '=' in negated_str:
raise InvalidInput(f'Negation rules must not have a config name: {rule_str}')
negated_str = rule_str[1:].strip()
if '=' in negated_str:
raise InvalidInput(f'Negation rules must not have a config name: {rule_str}')
if not negated_str:
raise InvalidInput(f'Negation rules must include a non-empty pattern: {rule_str}')

Copilot uses AI. Check for mistakes.
Comment thread idf_build_apps/utils.py
Comment on lines 31 to 39
- filename='sdkconfig.*', config_name=None - represents the set of configurations, names match the wildcard
value
- filename='sdkconfig.ci.test', negated=True - represents an exclusion rule, files matching this pattern
will be excluded from the build configurations

:param file_name: name of the sdkconfig file fragment, optionally with a single wildcard ('*' character).
can also be empty to indicate that the default configuration of the app should be used
:param config_name: name of the corresponding build configuration, or None if the value of wildcard is to be
used
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ConfigRule docstring states that config_name=None is used to indicate “use the wildcard value”, but the type is str and the implementation uses an empty string ('') for that behavior. Since this docstring was updated in this PR, please align it with the actual API (either document ''/omitted config name, or change the type/logic to truly support None).

Suggested change
- filename='sdkconfig.*', config_name=None - represents the set of configurations, names match the wildcard
value
- filename='sdkconfig.ci.test', negated=True - represents an exclusion rule, files matching this pattern
will be excluded from the build configurations
:param file_name: name of the sdkconfig file fragment, optionally with a single wildcard ('*' character).
can also be empty to indicate that the default configuration of the app should be used
:param config_name: name of the corresponding build configuration, or None if the value of wildcard is to be
used
- filename='sdkconfig.*', config_name='' - represents the set of configurations, names match the wildcard
value
- filename='sdkconfig.ci.test', negated=True - represents an exclusion rule, files matching this pattern
will be excluded from the build configurations
:param file_name: name of the sdkconfig file fragment, optionally with a single wildcard ('*' character).
can also be empty to indicate that the default configuration of the app should be used
:param config_name: name of the corresponding build configuration, or an empty string if the value of the
wildcard is to be used

Copilot uses AI. Check for mistakes.

To exclude specific `sdkconfig files`_, use the negation rule format: ``![SDKCONFIG_FILEPATTERN]``.

- ``SDKCONFIG_FILEPATTERN``: The format is the as in the normal Config Rule.
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar fix: “The format is the as in the normal Config Rule.” should be “The format is the same as in the normal Config Rule.”

Suggested change
- ``SDKCONFIG_FILEPATTERN``: The format is the as in the normal Config Rule.
- ``SDKCONFIG_FILEPATTERN``: The format is the same as in the normal Config Rule.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

Coverage

Coverage Report
FileStmtsMissCoverMissing
idf_build_apps
   __main__.py330%4–7
   app.py5698286%183, 228, 237–239, 271, 283, 339–340, 342, 351–352, 363–364, 424, 439, 477, 533–541, 551–552, 562, 580–581, 583, 599–608, 626–630, 645–648, 663–664, 682–683, 687–688, 699–701, 707, 720–722, 867–875, 885–915, 919–929, 1024–1030, 1033, 1055, 1075–1079
   args.py3773092%97, 174, 418–423, 433–438, 669, 672–673, 714, 737, 744–745, 757–759, 795–796, 943, 1022, 1024, 1109–1119, 1138
   autocompletions.py292417%16–23, 31–54
   finder.py102496%160, 177–179
   log.py681184%35, 39, 50, 60–69, 114
   main.py2417270%59, 64–68, 115, 120–124, 163, 187–189, 193–194, 200–213, 227–230, 241–270, 360–367, 376–377, 410–417, 420, 426–427, 433–435, 508–523
   session_args.py53787%46–50, 56, 70
   utils.py1892189%109, 126–127, 151, 199, 242, 269–275, 288–291, 305–311, 393
idf_build_apps/junit
   report.py94990%70, 80, 97–99, 125, 132–133, 158
   utils.py291066%18, 26–35
idf_build_apps/manifest
   manifest.py252897%183, 240–245, 352, 382–383, 402, 454
   soc_header.py220%4–6
idf_build_apps/vendors
   pydantic_sources.py58493%63, 66–69
TOTAL218228787% 

Tests Skipped Failures Errors Time
174 0 💤 0 ❌ 0 🔥 10m 23s ⏱️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants